package com.platform.api;

import com.platform.annotation.LoginUser;
import com.platform.entity.*;
import com.platform.params.SurveyAnswerParams;
import com.platform.params.SurveyQuestionParams;
import com.platform.service.ApiSurveyService;
import com.platform.util.ApiBaseAction;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "调查表")
@RestController
@RequestMapping("/api/questionnaire")
public class ApiSurveyController extends ApiBaseAction {

    @Autowired
    ApiSurveyService apiSurveyService;


    /**
     * 新增调查表
     */
    @ApiOperation(value = "新增调查表", response = Map.class)
    @PostMapping("saveSurvey")
    public Object saveSurvey(@RequestParam(value = "title",required = false) String title, @RequestParam(value = "surveyDesc",required = false) String surveyDesc,
                            @RequestParam(value = "displayStatus",required = false) Integer displayStatus){
        SurveyVo surveyVo = apiSurveyService.saveSurvey(title, surveyDesc, displayStatus);
        return toResponsSuccess(surveyVo);
    }

    /**
     * 新增问题表
     */
    @ApiOperation(value = "新增问题表", response = Map.class)
    @PostMapping("saveSurveyQuestion")
    public Object saveSurveyQuestion(@RequestBody List<SurveyQuestionParams> questionParamsList){
        List<SurveyQuestionVo> SurveyQuestionVoList = apiSurveyService.saveSurveyQuestion(questionParamsList);
        return toResponsSuccess(SurveyQuestionVoList);
    }

    /**
     * 新增回答表
     */
    @ApiOperation(value = "新增回答表", response = Map.class)
    @PostMapping("saveSurveyAnswer")
    public Object saveSurveyAnswer(@LoginUser UserVo loginUser, @RequestBody List<SurveyAnswerParams> answerParamsList){
        List<SurveyAnswersVo> SurveyQuestionVoList = apiSurveyService.saveSurveyAnswer(answerParamsList,loginUser);
        return toResponsSuccess(SurveyQuestionVoList);
    }

    /**
     * 查询问卷表
     */
    @ApiOperation(value = "查询问卷表",response = Map.class)
    @PostMapping("/getSurvey")
    public Object getSurvey(@RequestParam(value = "surveyId",required = false) Integer surveyId){
        SurveyVo surveyVo = apiSurveyService.getSurvey(surveyId);
        return toResponsSuccess(surveyVo);
    }
//    /**
//     * 新增回答表
//     */
//    @ApiOperation(value = "新增问题选择映射表", response = Map.class)
//    @PostMapping("saveSurveySelect")
//    public Object saveSurveySelect(@RequestBody List<SurveyAnswerParams> answerParamsList){
//        List<SurveyAnswersVo> SurveyQuestionVoList = apiSurveyService.saveSurveySelect(answerParamsList);
//        return toResponsSuccess(SurveyQuestionVoList);
//    }

    /**
     * 根据用户填写的调查表获取用户标签
     */
    @ApiOperation(value = "查询问卷表",response = Map.class)
    @PostMapping("/getTag")
    public Object getTag(@RequestParam(value = "surveyId",required = false) Integer surveyId){
        SurveyVo surveyVo = apiSurveyService.getSurvey(surveyId);
        return toResponsSuccess(surveyVo);
    }

    /**
     * 判断用户调查表是否已经填写
     * @param loginUser
     * @return
     */
    @ApiOperation(value = "调查表是否已经填写", response = Map.class)
    @PostMapping("/checkSurveyIsWrite")
    public Object checkSurveyIsWrite(@LoginUser UserVo loginUser){
        boolean checkSurveyFlag = apiSurveyService.checkSurveyIsWrite(loginUser);
        return toResponsSuccess(checkSurveyFlag);
    }

    /**
     * 根据用户填写的调查表推荐套餐
     * @return
     */
    @ApiOperation(value = "根据用户填写的调查表推荐套餐",response = Map.class)
    @PostMapping("/reconmmendCombo")
    public Object reconmmendCombo(@LoginUser UserVo loginUser){
        List<Map<String ,Object>> comboVoList = apiSurveyService.reconmmendCombo(loginUser);
        return toResponsSuccess(comboVoList);
    }

    /**
     * 根据套餐获取详情
     * @return
     */
    @ApiOperation(value = "根据套餐获取详情",response = Map.class)
    @PostMapping("/getComboInfoById")
    public Object getComboInfoById(@RequestParam(value = "id",required = true) Integer id){
        List<Map<String ,Object>> comboVoList = apiSurveyService.getComboInfoById(id);
        return toResponsSuccess(comboVoList);
    }

    /**
     * 管理员对调查表获取分析统计结果
     */
    private Object analyse(){
        return "";
    }
    /**
     * 管理员查询调查表结果
     */
    public Object querySurvey(){
        return "";
    }

    /**
     * 管理员修改调查表问题
     */

    public Object updateSurveyQuesstion(){
        return "";
    }



    /**
     * 管理员修改调查表选项答案
     */

    public Object updateSurveyAnswer(){
        return "";
    }
    /**
     * 管理员修改调查表名称/描述
     */

    public Object updateSurveyTitleOrDesc(){
        return "";
    }
    /**
     * 管理员删除调查表
     */

    public Object deleteSurvey(){
        return "";
    }
    /**
     * 用户登录系统之后查询默认弹出调查表
     */

    public Object defaultSurvey(){
        return "";
    }
    /**
     * 用户提交调查表
     */

    public Object conmitSurvey(){
        return "";
    }

//    /**
//     * 添加调查表
//     */
//    @ApiOperation(value = "添加或更新调查表", response = Map.class)
//    @PostMapping("save")
//    public Object save(@RequestBody SurveyUserVo surveyUserVo) {
//        apiSurveyService.insertQuestionnaire(surveyUserVo);
//        return toResponsSuccess(surveyUserVo);
//    }

}
